package com.dy.springcloud.controller;

import com.dy.springcloud.entity.Member;
import com.dy.springcloud.entity.Result;
import com.dy.springcloud.service.MemberOpenfeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
//MemberConsumerController可以访问 member-service 微服务
public class MemberConsumerController {

    //这里注入的是代理对象
    @Resource
    private MemberOpenfeignService memberOpenfeignService;


    @GetMapping("/member/consumer/get/{id}")
    public Result getMemberById(@PathVariable("id") Long id) {
        log.info("getMemberById"+id);
        //openfeign使用get方法访问微服务                                                         返回类型
        return memberOpenfeignService.getMemberById(id);
    }


}
